import { siteConfig, NavData } from '@/config/site'

export function StructuredData() {
  // 网站基本信息结构化数据
  const websiteSchema = {
    "@context": "https://schema.org",
    "@type": "WebSite",
    "name": siteConfig.name,
    "description": siteConfig.description,
    "url": "https://mini.hello123.com",
    "inLanguage": "zh-CN",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://mini.hello123.com/?search={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    },
    "author": {
      "@type": "Organization",
      "name": "Hello123导航",
      "url": "https://mini.hello123.com"
    },
    "publisher": {
      "@type": "Organization", 
      "name": "Hello123导航",
      "url": "https://mini.hello123.com",
      "logo": {
        "@type": "ImageObject",
        "url": "https://mini.hello123.com/hello123.png",
        "width": 512,
        "height": 512
      }
    }
  }

  // 组织信息结构化数据
  const organizationSchema = {
    "@context": "https://schema.org",
    "@type": "Organization",
    "name": "Hello123导航",
    "description": "提供精选网站导航服务，涵盖AI工具、搜索引擎、开发工具等多个分类",
    "url": "https://mini.hello123.com",
    "logo": {
      "@type": "ImageObject",
      "url": "https://mini.hello123.com/hello123.png",
      "width": 512,
      "height": 512
    },
    "foundingDate": "2024",
    "sameAs": [
      siteConfig.links.github,
      siteConfig.links.twitter
    ],
    "contactPoint": {
      "@type": "ContactPoint",
      "contactType": "customer service",
      "availableLanguage": "Chinese"
    }
  }

  // 导航分类列表结构化数据
  const itemListSchema = {
    "@context": "https://schema.org",
    "@type": "ItemList",
    "name": "Hello123导航分类",
    "description": "网站导航分类列表，包含AI工具、搜索引擎、社交媒体等多个类别",
    "numberOfItems": NavData.length,
    "itemListElement": NavData.map((category, index) => ({
      "@type": "ListItem",
      "position": index + 1,
      "name": category.title,
      "description": `${category.title}相关网站和工具的导航分类，包含${category.items.length}个精选网站`,
      "url": `https://mini.hello123.com#${encodeURIComponent(category.title)}`,
      "item": {
        "@type": "WebPage",
        "name": `${category.title} - Hello123导航`,
        "description": `${category.title}分类下的精选网站导航`
      }
    }))
  }

  // 网站导航结构化数据
  const siteNavigationElementSchema = {
    "@context": "https://schema.org",
    "@type": "SiteNavigationElement",
    "name": "主导航",
    "url": "https://mini.hello123.com"
  }

  // 面包屑导航结构化数据
  const breadcrumbSchema = {
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "itemListElement": [
      {
        "@type": "ListItem",
        "position": 1,
        "name": "首页",
        "item": "https://mini.hello123.com"
      }
    ]
  }

  return (
    <>
      {/* 网站基本信息 */}
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{
          __html: JSON.stringify(websiteSchema),
        }}
      />
      
      {/* 组织信息 */}
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{
          __html: JSON.stringify(organizationSchema),
        }}
      />
      
      {/* 导航分类列表 */}
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{
          __html: JSON.stringify(itemListSchema),
        }}
      />
      
      {/* 网站导航元素 */}
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{
          __html: JSON.stringify(siteNavigationElementSchema),
        }}
      />
      
      {/* 面包屑导航 */}
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{
          __html: JSON.stringify(breadcrumbSchema),
        }}
      />
    </>
  )
} 